package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author itlxc
 * @since 2024-07-26
 */
@RestController
@RequestMapping("/api/v1/material")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "app端素材管理")
public class WmMaterialController {

    private final WmMaterialService wmMaterialService;

    /**
     * 上传图片
     * @param multipartFile
     * @return
     */
    @PostMapping("/upload_picture")
    @ApiOperation("上传图片")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {
        log.info("上传图片:{}", multipartFile.getOriginalFilename());
        return wmMaterialService.uploadPicture(multipartFile);
    }

    /**
     * 素材列表查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("素材列表查询")
    public ResponseResult findList(@RequestBody WmMaterialDto dto){
        log.info("素材列表查询:{}", dto);
        return wmMaterialService.findList(dto);
    }
}
